<?php

/**
 * FootballFactory, Copyright Robin Loop & Pascal Wirz, 2014
 * ---
 * Template zum Auflisten der Spieler
 *
 * @author Robin
 */

require('templates/header.php');
?>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <!-- JQuery -->
        <script src="../js/jquery-1.8.3.min.js"></script>
        <script src="../js/jquery-ui-1.9.2.custom.min.js"></script>
        
        <!-- JS -->
        <script src="../js/admin_menu.js"></script>
        <script src="../js/admin_player.js"></script> 
        
        <!-- CSS -->
        <link href="../css/admin.css" rel="stylesheet">
        <link href="../css/smoothness/jquery-ui-1.9.2.custom.css" rel="stylesheet">
        
    </head>

    <body>
        
        <?php include 'menu.php'; ?>
        
        <div>
            <h1>Spieler</h1>
                
            <div>
				<p>
					<select id="teamlist">
						<option value="-1" <?php if ($teamId == -1) { echo "selected"; } else { echo ""; } ?>>Alle Teams</option>
						<?php foreach ($teams as $team) { ?>
						<option value="<?php echo $team->getId(); ?>" <?php if ($team->getId() == $teamId) { echo "selected"; } else { echo ""; } ?>><?php echo $team->getName(); ?></option>
						<?php } ?>
					</select>
					<select id="seasonlist">
						<option value="-1" <?php if ($seasonId == -1) { echo "selected"; } else { echo ""; } ?>>Alle Saisons</option>
						<?php foreach ($seasons as $season) { ?>
						<option value="<?php echo $season->getId(); ?>" <?php if ($season->getId() == $seasonId) { echo "selected"; } else { echo ""; } ?>><?php echo $season->getName(); ?></option>
						<?php } ?>
					</select>
				</p>
				
                <table>
                    <tr>
                      <th>ID</th>
                      <th>Vorname</th>
                      <th>Nachname</th>
                      <th>Team</th>
					  <th>Status</th>
                      <th></th>
                      <th></th>
                    </tr>
                    <?php foreach ($players as $player) { ?>
                    <tr>
                        <td><?php echo $player->getId()?></td>
                        <td><?php echo $player->getFirstname()?></td>
                        <td><?php echo $player->getLastname()?></td>
                        <td><?php echo $player->getTeam()?></td>
                        <td><?php echo $player->getStatus()?></td>
                        <td><a href="player.php?action=edit&amp;playerId=<?php echo $player->getId()?>">editieren</a></td>
                        <td><!--<a href="player.php?action=delete&amp;playerId=<?php echo $player->getId()?>" onclick="return confirm('Spieler loeschen?')">loeschen</a>--></td>
                    </tr>  
                    <?php } ?>
                </table>
                <p>Anzahl Spieler: <?php echo $numbPlayers ?></p>
                <p><a href="player.php?action=new">Neuen Spieler erfassen</a></p>
            </div>
        </div>
    </body>
</html>